﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kronos.Classes;
using System.IO;
using LinqToExcel;
namespace Kronos
{
    public partial class LoggedIn : System.Web.UI.Page
    {
        public string Username;

        protected void Page_Load(object sender, EventArgs e)
        {
            Username=LoginModel.UserRedirectionValidation();
            UserInformation.UsernameThatIsLoggedIn = Username;
            UserInformation.usernameMessage.Text = "HIII";
        }

        protected void UploadButton_Click(object sender, EventArgs e)
        {
            //upload transcript you save it from my concordia as an excel document, is what I am thinking 
            if (FileUploadControl.HasFile)
            {
                try
                {
                    if (FileUploadControl.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")//this means it has to be excel file type
                    {
                        if (FileUploadControl.PostedFile.ContentLength < 102400)//less the 100kbs
                        {
                            FileUploadControl.SaveAs(Server.MapPath("/transcripts/") + Username+".xlxs"); //save it in transcripts folder
                            StatusLabel.Text = "Upload status: File uploaded!";
                        }
                        else
                            StatusLabel.Text = "Upload status: The file has to be less than 100 kb!";
                    }
                    else
                        StatusLabel.Text = "Upload status: Only Excel 2007 files format are accepted!";
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = "Upload status: Exception Occured  " + ex.Message;
                }
            }
            
            /*try
            {
                ExcelDataExtract TheSpreadsheet = new ExcelDataExtract(Username_logged_in);
            }
            catch (Exception error)
            {
                throw new Exception(error.ToString());
            }
             * */
        }







    }
}